package com.glut.campusrepair.controller;

import com.glut.campusrepair.entity.MaintenanceRecords;
import com.glut.campusrepair.service.IMaintenanceRecordsGetService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 *  前端控制器
 *
 * @author stubborn
 * @since 2024-07-20 15:22
 */
@RestController
@Slf4j
@CrossOrigin
public class MaintenanceRecordsGetController {

    @Autowired
    private IMaintenanceRecordsGetService maintenanceRecordsGetService;

    @GetMapping("/maintenance-records/user/{userNo}")
    public List<MaintenanceRecords> getRecordsByUserNo(@PathVariable Integer userNo) {
        return maintenanceRecordsGetService.getRecordsByUserNo(userNo);
    }

    @PostMapping("/maintenance-records/save")  //前端：axios.post()
    public boolean save(@RequestBody MaintenanceRecords maintenanceRecords) { //@RequestBody将请求的JSON数据解析成POJO对象

        return maintenanceRecordsGetService.save(maintenanceRecords);

    }
}












